import com.epidemy._

import scala.actors.remote.Node

/*
sh test
*/
object EpidemyTest {
    def main(args: Array[String]): Unit = {
        
        Grid.start
        
        var rmtAdrRx = """([^:]+):(\d+)""".r
        for (rmtAdrRx(serv, port) <- args)
            Grid.localNodeActor ! Grid.ConnectTo(Grid.GridNode(Node(serv, port.toInt), 'GridNode0))
        
        var ns = Grid.nodes
        while (ns.size < 2) {
          println("Waiting...")
          Thread.sleep(1)
          ns = Grid.nodes
        }
        for (node <- ns) {
          println("Asking for execution on " + node)
          node exec {
            println("Hello world !")
            new java.io.FileOutputStream("test.txt").close
            println("Wrote !")
          }
        }
    }
}
